﻿using CinemaMaestro.BusinessLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CinemaMaestro.BusinessLayer
{
    public class Languages : BusinessObjectBase, ILanguages
    {
        public Languages(IUnitOfWork uow)
            : base(uow)
        { }

        public Language Create(Language language)
        {
            var createdLanguage = _uow.LanguageRepository.Create(language);
            _uow.SaveChanges();
            return createdLanguage;
        }

        public bool Delete(int id)
        {
            var deleted = _uow.LanguageRepository.Delete(id);
            _uow.SaveChanges();
            return deleted;
        }

        public IQueryable<Language> Read()
        {
            return _uow.LanguageRepository.Read();
        }

        public void Update(Language entity)
        {
            _uow.LanguageRepository.Update(entity);
            _uow.SaveChanges();
        }
    }
}
